<template>
  <div class="template-index-Lu">
    <commpVxeTable
      :key="reCommpVxeTable"
      :conditionBtnRow="true"
      :config="dataTableConfig"
      :columns="columnsVxe"
      :formItem="formItem"
      ref="administrativeOffice"
      @checkboxChange="checkboxChange"
      @searchEvent="searchEvent"
      @resetEvent="resetEvent"
      >
      <template v-slot:externalOperations="{data}"  >
        <vxe-form-item>
          <template>
            <a-button type="primary" class="red-btn" @click="deleteClick">批量删除</a-button>
          </template>
        </vxe-form-item>
      </template>
    </commpVxeTable>
  </div>
</template>
<script>
import assessCheckApi from './service/api.js'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import {deleteBatch} from './service/index'
export default {
  components: {
    commpVxeTable
  },
  data() {
    return {
      reCommpVxeTable: '',
      dataTableConfig: {
        api: assessCheckApi.list,
        rowId: 'id',
        urlType: true,
        paramet: {}
      },
      columnsVxe:[
        {
          type: 'checkbox',
          width: 60,
          fixed: 'left'
        },{
          title: '姓名',
          field: 'fuserName',
          width: 80,
        },
        // {
        //   title: '性别',
        //   field: 'fxb',
        // },
        {
          title: '部门',
          field: 'fbm',
        },{
          title: '职务',
          field: 'fzw',
        },{
          title: '参加工作时间',
          field: 'fcjgzsj',
          width: 150
        },{
          title: '工龄',
          field: 'fgl',
          width: 50
        },{
          title: '年度',
          field: 'fnd',
          width: 100
        },
        // {
        //   title: '工作单位',
        //   field: 'fgzdw',
        // },
        {
          title: '年休假',
          align:"center",
          children: [
            {
              title: '效期开始时间',
              field: 'fnxjxqkssj',
            },{
              title: '效期结束时间',
              field: 'fnxjxqjssj',
            },{
              title: '可休天数',
              field: 'fnxjxqjssj',
              width: 100
            },{
              title: '转结天数',
              field: 'fnxjzjts',
              width: 100
            },{
              title: '剩余天数',
              field: 'fnxjsyts',
              width: 100
            },
          ],
        },
      ],
      formItem: [
        {
          label: '年度',
          model: 'fnd',
        },
      ],
      idList: [],
    }
  },
  created() {
  },
  methods: {
    // 勾选
    checkboxChange(val){
      //console.log('已选择',val)
      this.idList = []
      if(val.length){
        val.forEach(item => {
            this.idList.push(item.id)
        });
      }
    },
    // 搜索
    searchEvent(){
      this.dataTableConfig.paramet = {
        ...this.dataTableConfig.paramet,
      }
      //console.log(this.dataTableConfig.paramet)
    },
    // 重置
    resetEvent(){
      this.dataTableConfig.paramet = {
        ...this.dataTableConfig.paramet,
      }
    },
    // 年休假历史存储记录-批量删除
    deleteClick(){
      if(this.idList.length == 0){
        this.$message.error('请选择删除项')
      } else {
        var that = this
        that.$confirm({
          title: '你确定批量删除这些记录吗?',
          content: '',
          okText: '确定',
          okType: 'danger',
          cancelText: '取消',
          onOk() {
            let list = that.idList.toString()
            deleteBatch({ids:list}).then(res => {
              if(res.code == 200){
                that.reCommpVxeTable = Date.now()
                that.$message.success(res.message)
              } else {
                that.$message.warning(res.message)
              }
            })
          },
          onCancel() {
            //console.log('Cancel');
          },
        });
      }
    }
  },
}
</script>
<style>
@import url('../../css/oaClass.css');
</style>
